package com.company.planner.web.screens.indexs;

import com.company.planner.entity.Indexs;
import com.haulmont.cuba.core.global.DataManager;
import com.haulmont.cuba.gui.Notifications;
import com.haulmont.cuba.gui.components.DataGrid;
import com.haulmont.cuba.gui.screen.*;

import javax.inject.Inject;

@UiController("planner_Indexs.browse")
@UiDescriptor("indexs-browse.xml")
@LookupComponent("indexsesTable")
@LoadDataBeforeShow
public class IndexsBrowse extends StandardLookup<Indexs> {
    @Inject
    private DataManager dataManager;
    @Inject
    private Notifications notifications;

    @Subscribe("indexsesTable")
    public void onIndexsesTableEditorPostCommit(DataGrid.EditorPostCommitEvent event) {
        Indexs item = (Indexs) event.getItem();
        if (item.getState() != null) {
            dataManager.commit(item);
        } else {
            notifications.create(Notifications.NotificationType.TRAY)
                    .withCaption("不能将开关修改为空")
                    .show();
        }
    }
}